package model

import (
	"iris-wms/common/tools/consts"

	"gorm.io/gorm"
)

// 单据总表
type WmsBill struct {
	gorm.Model
	WorkType   consts.WorkType `json:"workType" gorm:"not null;default:0;comment:业务类型;"`
	IoStatus   uint            `json:"ioStatus" gorm:"not null;default:0;comment:出入库状态;"` // dict
	IoType     uint            `json:"ioType" gorm:"not null;default:0;comment:出入库类型;"`   // dict
	Name       string          `json:"name" gorm:"not null;default:'';"`
	Code       string          `json:"code" gorm:"not null;default:'';uniqueIndex;"`
	OrderCode  string          `json:"orderCode" gorm:"not null;default:'';comment:关联的订单号;"`
	SupplierId uint            `json:"supplierId" gorm:"not null;"`
	CustomerId uint            `json:"customerId" gorm:"not null;"`
	Uid        uint            `json:"uid" gorm:"not null;default:0;"`
	Euid       uint            `json:"euid" gorm:"not null;default:0;comment:编辑人"`
	WorkAt     string          `json:"workAt" gorm:"size:20;type:string;not null;default:'';comment:实际业务时间，有可能是补单;"`
	Memo       string          `json:"memo" gorm:"not null;default:'';"`
}

type WmsBillGoods struct {
	ID      uint            `json:"ID" gorm:"primaryKey"`
	BillId  uint            `json:"billId" gorm:"not null;"`
	Wid     uint            `json:"wid" gorm:"not null;comment:仓库ID;"`
	GoodsId uint            `json:"goodsId" gorm:"not null;default:0;"`
	PlanQty float64         `json:"planQty" gorm:"type:decimal(12,2);not null;default:0;comment:计划数量;"`
	Qty     float64         `json:"qty" gorm:"type:decimal(12,2);not null;default:0;comment:实际数量;"`
	Price   float64         `json:"price" gorm:"type:decimal(12,2);not null;default:0;comment:单价;"`
	Mark    consts.BillMark `json:"mark" gorm:"not null;default:0;comment:进出方向(用于统计库存) -1=出 1=进;"`
	IsGift  int8            `json:"isGift" gorm:"not null;default:0;comment:1=是赠品"`
	SrcWid  uint            `json:"srcWid" gorm:"not null;default:0;comment:移出仓ID;"`
	DestWid uint            `json:"destWid" gorm:"not null;default:0;comment:移入仓ID;"`
	Memo    string          `json:"memo" gorm:"not null;default:'';"`
}

type WmsBillLogistics struct {
	ID      uint   `json:"ID" gorm:"primaryKey"`
	BillId  uint   `json:"billId" gorm:"not null;"`
	Cid     uint   `json:"cid" gorm:"not null;default:0;"`
	SendAt  string `json:"sendAt" gorm:"size:20;type:string;not null;default:'';comment:发货日期;"`
	Waybill string `json:"waybill" gorm:"not null;default:'';comment:运单号;"`
	Memo    string `json:"memo" gorm:"not null;default:'';"`
}
